package com.charging.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.charging.common.annotation.Log;
import com.charging.common.core.controller.BaseController;
import com.charging.common.core.domain.AjaxResult;
import com.charging.common.enums.BusinessType;
import com.charging.system.domain.KxRefundRecord;
import com.charging.system.service.IKxRefundRecordService;
import com.charging.common.utils.poi.ExcelUtil;
import com.charging.common.core.page.TableDataInfo;

/**
 * 退款记录Controller
 *
 * @author charging
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/system/refund_record")
public class KxRefundRecordController extends BaseController
{
    @Autowired
    private IKxRefundRecordService kxRefundRecordService;

    /**
     * 查询退款记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:refund_record:list')")
    @GetMapping("/list")
    public TableDataInfo list(KxRefundRecord kxRefundRecord)
    {
        startPage();
        List<KxRefundRecord> list = kxRefundRecordService.selectKxRefundRecordList(kxRefundRecord);
        return getDataTable(list);
    }

    /**
     * 导出退款记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:refund_record:export')")
    @Log(title = "退款记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KxRefundRecord kxRefundRecord)
    {
        List<KxRefundRecord> list = kxRefundRecordService.selectKxRefundRecordList(kxRefundRecord);
        ExcelUtil<KxRefundRecord> util = new ExcelUtil<KxRefundRecord>(KxRefundRecord.class);
        util.exportExcel(response, list, "退款记录数据");
    }

    /**
     * 获取退款记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:refund_record:query')")
    @GetMapping(value = "/{refundRecordId}")
    public AjaxResult getInfo(@PathVariable("refundRecordId") Long refundRecordId)
    {
        return success(kxRefundRecordService.selectKxRefundRecordByRefundRecordId(refundRecordId));
    }

    /**
     * 新增退款记录
     */
    @PreAuthorize("@ss.hasPermi('system:refund_record:add')")
    @Log(title = "退款记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KxRefundRecord kxRefundRecord)
    {
        return toAjax(kxRefundRecordService.insertKxRefundRecord(kxRefundRecord));
    }

    /**
     * 修改退款记录
     */
    @PreAuthorize("@ss.hasPermi('system:refund_record:edit')")
    @Log(title = "退款记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KxRefundRecord kxRefundRecord)
    {
        return toAjax(kxRefundRecordService.updateKxRefundRecord(kxRefundRecord));
    }

    /**
     * 删除退款记录
     */
    @PreAuthorize("@ss.hasPermi('system:refund_record:remove')")
    @Log(title = "退款记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refundRecordIds}")
    public AjaxResult remove(@PathVariable Long[] refundRecordIds)
    {
        return toAjax(kxRefundRecordService.deleteKxRefundRecordByRefundRecordIds(refundRecordIds));
    }
}
